package org.jeecg.modules.service;

import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.jeecg.modules.device.Device;
import org.jeecg.modules.entity.TigDevice;

import java.time.LocalDate;
import java.util.Date;
import java.util.List;

public interface DeviceService {

    public Device getDevice(String deviceId);

    public TigDevice getTigDevice(String deviceId);

    public Boolean reloadDevice(String deviceId);

    boolean login(String deviceId, Boolean isManual);

    void saveDevice(Device device);

    boolean disconnect(String deviceId, Boolean isManual);

    boolean runCommand(String cmd, JSONObject deviceData);

    //移除设备
    public boolean removeDevice(String deviceId);

    void saveDeviceToRedis(String deviceId, JSONObject jo);

    void resetDeviceState();

    List<TigDevice> getActiveDevices();

    List<TigDevice> getDevices();

    public int getOnlineDevicesCount(String org_code);

    public int getOfflineDevicesCount(String org_code);

    public int getDevicesCount(String org_code);

    //获取预警数目
    public int getWarningCount(String orgCode, int warnType, LocalDate date);

    //获取设备指定类型预警数
    public int getWarningCountByDeviceId(String id, int warnType);

    //设备操作日志
    public void generateDeviceOperateLog(String deviceId, String warningType, String warningMsg) throws Exception;

    //设备发送通知到部门级上级
    public void sendAnnouncementToDepartment(String deviceId, String name, String msg) throws Exception;

    public void saveBaseDeviceLog(TigDevice tigDevice) throws Exception;

    //根据IP和端口判断是否存在冲突
    public Boolean isExistSameDevice(TigDevice tigDevice);

    //根据机构码判断该机构下是否存在设备
    public Boolean isExistDevicesByOrgCode(String orgCode);
}
